<template>
  <div class="dashboard-editor-container">
    <PanelGroup @handleSetLineChartData="handleSetLineChartData"/>

    <div class="chart-line">
      <line-chart :chart-data="lineChartData" :yTittle="yTitle"/>
    </div>

    <el-row :gutter="20" class="chart-row">
      <!--<el-col :xs="24" :sm="24" :lg="12">
        <el-card>
          <bar-chart />
        </el-card>
      </el-col>-->
      <el-col :xs="24" :sm="24" :lg="10" :margin-right="20">
        <el-card :body-style="style">
          <pie-chart />
        </el-card>
      </el-col>

      <el-col :xs="24" :sm="24" :lg="10">
        <el-card>
          <bar-chart2 />
        </el-card>
      </el-col>

      <el-button class="button" type="primary" @click="markdownFn">近期订单分析记录</el-button>
    </el-row>

    <el-row :gutter="20">
      <!--<el-col :xs="24" :sm="24" :lg="8">
        <el-card>
          <line-chart2 />
        </el-card>
      </el-col>-->
      <!--<el-col :xs="24" :sm="24" :lg="8">
        <el-card>
          <bar-chart2 />
        </el-card>
      </el-col>-->
      <!--<el-col :xs="24" :sm="24" :lg="8">
        <el-card>
          <pie-chart2/>
        </el-card>
      </el-col>-->
    </el-row>
    <div>
      <markdown v-if="flag"></markdown>
    </div>
  </div>
</template>

<script>
import markdown from './markdown/Markdown'
import PanelGroup from './components/PanelGroup'
import LineChart from './components/LineChart'
// import BarChart from './components/BarChart'
import PieChart from './components/PieChart'

// import LineChart2 from './components/LineChart2'
import BarChart2 from './components/BarChart2'
// import PieChart2 from './components/PieChart2'

const lineChartDatas = {
  purchases: {
    allOrder: [150, 180, 170, 170, 160, 170,180],
    waitOrder: [80, 100, 121, 104, 105, 90, 100],
    doingOrder: [120, 90, 100, 138, 142, 130, 130],
    finishOrder: [30, 60, 100, 80, 40, 50, 20],
    refundOrder: [10, 5, 15, 3, 12, 4, 9]
  },
  /*shoppings: {
    waitOrder: [130, 140, 141, 142, 145, 150, 160],
    doingOrder: [120, 82, 91, 154, 162, 140, 130]
  },
  newUsers: {
    waitOrder: [100, 120, 161, 134, 105, 160, 165],
    doingOrder: [120, 82, 91, 154, 162, 140, 145]
  },
  messages: {
    waitOrder: [200, 192, 120, 144, 160, 130, 140],
    doingOrder: [180, 160, 151, 106, 145, 150, 130]
  },*/
}

const yTitles = {
  purchases: '订单数量(个)',
  /*shoppings: '订单数量(个)',
  newUsers: '客户数量(人)',
  messages: '消息数量(条)',*/
}

export default {
  name: 'DashBoard',

  data() {
    return {
      flag: false,
      style:{
        "height": "440px"
      },
      lineChartDatas: [],
      // lineChartData: lineChartDatas.purchases,
      lineChartData: {},
      yTitle: yTitles.purchases
    }
  },

  mounted () {
    setTimeout(() => {
      this.lineChartDatas = lineChartDatas
      this.lineChartData = lineChartDatas.purchases
    }, 1000);
  },

  methods: {
    handleSetLineChartData(type) {
      this.yTitle = yTitles[type]
      this.lineChartData = lineChartDatas[type]
    },
    markdownFn(){
      this.flag = !this.flag
    }
  },

  components: {
    PanelGroup,
    LineChart,
    // BarChart,
    PieChart,
    // LineChart2,
    BarChart2,
    markdown
    // PieChart2,
  }
}
</script>

<style lang="less" scoped>
.dashboard-editor-container {
  padding: 32px;
  background-color: rgb(240, 242, 245);
  .chart-line {
    background:#fff;
    padding:16px 0 0 16px;
    margin-bottom:32px;
  }
  .chart-row {
    margin-bottom: 32px;
    position: relative;
    .button{
      position: absolute;
      bottom: 0;
    }
  }
}
</style>
